﻿@{
    ViewBag.Title = "Form"; 
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    layui.use(['jquery', 'form', 'laydate', 'common','optimizeSelectOption'], function () {
        var form = layui.form,
            $ = layui.$,
            common = layui.common,
            laydate = layui.laydate;
        var keyValue = $.request("keyValue");
        //权限字段
        common.authorizeFields('adminform');
        //此处需修改
        //类型为时间时
        //laydate.render({
            //elem: '#F_Birthday'
            //, btns: ['clear', 'now']
            //, trigger: 'click',
            //format: 'yyyy-MM-dd',
        //});

        $(function () {
            initControl();
            if (!!keyValue) {
                 common.ajax({
                   url: '/SystemOrganize/Transfer/GetFormJson',
                   dataType: 'json',
                   data: { keyValue: keyValue },
                   async: false,
                   success: function (data) {
                       common.val('adminform', data);
                    }
               });
           }
           form.render();
       });
       wcLoading.close();

       function initControl() {
           //此处需修改
           //绑定数据源
           //类型为下拉框时
                $("#F_OutPostId").bindSelect({
                 url: "/SystemOrganize/Duty/GetListJson",
                 id: "F_Id",
                 text: "F_FullName"
             });
                  $("#F_InPostId").bindSelect({
                 url: "/SystemOrganize/Duty/GetListJson",
                 id: "F_Id",
                 text: "F_FullName"
             });
       }

       //监听提交
       form.on('submit(saveBtn)', function (data) {
           var postData = data.field;
                postData["F_OutPost"]= $("#F_OutPostId option:selected").text();
                 postData["F_InPost"]= $("#F_InPostId option:selected").text();
           common.submitForm({
               url: '/SystemOrganize/Transfer/SubmitForm?keyValue=' + keyValue,
               param: postData,
               success: function () {
                   common.parentreload('data-search-btn');
               }
           })
           return false;
       });
   });
    function search(fileds) {
          layui.use(['jquery', 'form', 'common'], function () {
              var form = layui.form,
                  $ = layui.$,
                  common = layui.common;
        
              //不同弹窗
               if (fileds == '转出部门') {
                  common.modalOpen({
                      title: "选择组织",
                            url: "/SystemOrganize/Organize/AddForm?name=" + "F_OutOrg" + "&value=" + "F_OutOrgId" + "&ids=" + $('#F_OutOrgId').val(),
                      width: "650px",
                      height: "600px",
                  });
              }
               else if (fileds == '转入部门') {
                   common.modalOpen({
                       title: "选择组织",
                              url: "/SystemOrganize/Organize/AddForm?name=" + "F_InOrg" + "&value=" + "F_InOrgId" + "&ids=" + $('#F_InOrgId').val(),
                        width: "650px",
                       height: "600px",
                   });
               }
              else   if (fileds == '人员') {
                     common.modalOpen({
                         title: "选择人员",
                             url: "/SystemOrganize/User/AddForm4?name=" + "F_RealName" + "&num="+"F_UserNum"+"&value=" + "F_UserId" + "&ids=" + $('#F_UserId').val(),
                         width: "650px",
                         height: "600px",
                     });
                       
                  }
              else {
                  return false;
              }
             
              
          }); 
       
          
      }
         var re=function(){
              layui.form.render();
          }
</script>

<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <div class="layui-form layuimini-form" lay-filter="adminform">
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">工号</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_UserNum" name="F_UserNum" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input" onclick="search('人员')">
                        <input type="text" id="F_UserId" name="F_UserId" hidden>

                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">姓名</label>
                    <div class="layui-input-block">
                        <input type="text" id="F_RealName" name="F_RealName" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label required">转出部门</label>
                   <div class="layui-input-block">
                        <input type="text" id="F_OutOrg" name="F_OutOrg" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input" onclick="search('转出部门')">
                        <input type="text" id="F_OutOrgId" name="F_OutOrgId" hidden>
                  
                   </div>
               </div>
                <div class="layui-form-item layui-hide">
                    <label class="layui-form-label required">转出岗位</label>
                    <div class="layui-input-block">
                        <select id="F_OutPostId" name="F_OutPostId" lay-verify="required" lay-search="">
                            <option value="">==请选择==</option>
                        </select>
                        <input type="text" id="F_OutPost" name="F_OutPost" hidden>
                        
                    </div>
                </div>
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label required">转入部门</label>
                   <div class="layui-input-block">
                        <input type="text" id="F_InOrg" name="F_InOrg" autocomplete="off" lay-verify="required" placeholder="请输入" class="layui-input" onclick="search('转入部门')">
                        <input type="text" id="F_InOrgId" name="F_InOrgId" hidden>
                        
                   </div>
               </div>
                
               
               
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label required">转入岗位</label>
                   <div class="layui-input-block">
                        <select id="F_InPostId" name="F_InPostId" lay-verify="required" lay-search="">
                            <option value="">==请选择==</option>
                        </select>
                        <input type="text" id="F_InPost" name="F_InPost" hidden>
                   </div>
               </div>
                
                <div class="layui-form-item layui-hide">
                   <label class="layui-form-label ">备注</label>
                   <div class="layui-input-block">
                        <input type="text" id="F_Description" name="F_Description" autocomplete="off"  placeholder="请输入" class="layui-input">
                   </div>
               </div>
                <div class="layui-form-item layui-hide">
                    <button class="layui-btn site-demo-active" lay-submit id="submit" lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </div>
    </div>
</body>

